﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfAddTransport.aspx.cs" Inherits="msBsc.WebUi.ShpMana.wfAddTransport" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>运输证</title>
    <link href="/themes/wStyle1/css/sLayout.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sHead.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/sFoot.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/usermenu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/from.css" rel="stylesheet" />
    <link href="/jqPlugin/hdfu/hdfu.css" rel="stylesheet" />
    <link href="/themes/wStyle1/css/Seller/sReleaseForum.css" rel="stylesheet" />
    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <link href="/jqPlugin/layer/skin/layer.css" rel="stylesheet" />
    <link href="/jqPlugin/laydate/skins/default/laydate.css" rel="stylesheet" />
    <style type="text/css">
        .texarea {
            width: 648px;
            height: 150px;
        }

        #logo_img_selected img {
            max-height: 300px;
            /*max-width:150px;*/
        }

        .selCondition li {
            background-color: #f5f5f5;
            border: 1px solid #f5f5f5;
            float: left;
            line-height: 20px;
            margin-right: 5px;
            margin-top: 3px;
            padding: 4px 10px;
        }

        .divMaxCondition {
            display: inline;
            float: left;
            text-align: left;
            width: 720px;
        }

        .cancel {
            cursor: pointer;
            padding-left: 5px;
        }

        .additem {
            margin-left: 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="wf_all">
        <div class="main-container">
            <div class="main-Info" style="margin-bottom: 200px;">
                <div class="main-horizontal">
                    <div class="r_row">
                        <span class="control-span">地接客<span class="required">*</span></span><div class="controls">
                            <input type="text" id="djackId" readonly="readonly" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">证件号<span class="required">*</span></span><div class="controls">
                            <input type="text" id="transportNumber" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">业户名称<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="businessName" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">住址<span class="required">*</span></span>
                        <div class="controls">
                            <select class="selArea" id="selCountry">
                                <option value="DF6723BE-A25C-4F77-BB49-A1662D3E6F2A">中国</option>
                                <option value="453370FE-8295-41EC-A41C-B6F650AD1B4C">亚洲</option>
                                <option value="927D5F28-C4FB-46A9-940C-B07DF0A04018">北美洲</option>
                                <option value="1FEAF456-7C76-41C8-A3D0-F9C12415A736">南美洲</option>
                                <option value="4E2B4524-E9CB-4E20-9224-E58EB636D1C7">非洲</option>
                                <option value="67FA6A8D-951C-4B53-AE1E-70DCB97E11DE">欧洲</option>
                                <option value="0B772F3D-D8F8-42E3-9019-81FE6F772236">大洋洲</option>
                            </select>
                            <select class="selArea" id="selCity">
                                <option value="">请选择</option>
                            </select>
                            <select class="selArea" id="selDestination">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                     <div class="r_row">
                        <span class="control-span">车牌号<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="vehicleNumber" class="input titleInput" />
                        </div>
                    </div>

                    <div class="r_row">
                        <span class="control-span">许可证号<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="licenseNumber" class="input titleInput" />
                        </div>
                    </div>

                    <div class="r_row">
                        <span class="control-span">车辆品牌<span class="required">*</span></span>
                        <div class="controls">
                            <select id="vehicleBrand" class="input titleInput"></select>
                        </div>
                    </div>                   

                    <div class="r_row">
                        <span class="control-span">座位数<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="seats" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">经营范围<span class="required"> </span></span>
                        <div class="controls">
                            <input type="text" id="businessScope" class="input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">发证日期<span class="required">*</span></span>
                        <div class="controls">
                            <input type="text" id="issuingDate" onclick="laydate({ min: '1099-06-16 23:59:59', max: laydate.now(), format: 'YYYY-MM-DD' })" class="laydate-icon input titleInput" />
                        </div>
                    </div>
                    <div class="r_row">
                        <span class="control-span">运输证<span class="required">*</span></span>
                        <div class="controls">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <div id="logo_img_selected">
                                            <img id="uHeadImg" src="/themes/Style1/Image/u_head_110x110.png" for="" />
                                        </div>
                                    </td>
                                    <td style="padding: 3px;">
                                        <div style="padding: 5px;">
                                            <a id="btnupImg" target="_self" value="上传图片" style="margin: 6px; cursor: pointer;" onclick="javascript:return false;">上传图片</a>
                                            <p>
                                                文件大小不能大于1M
                                            </p>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div style="text-align: center; margin-top: 20px;">
                        <input type="button" onclick="addTransport();" class="releaseBtn" style="margin-right: 20px;" value="发布" />
                    </div>
                </div>
            </div>
        </div>
        <!--start JS引用-->
        <script src="/jqPlugin/js/jquery-1.8.3.min.js"></script>
        <script src="/jqPlugin/js/jBase.js"></script>
        <script src="/jqPlugin/js/jBPage.js"></script>
        <script src="/jqPlugin/js/laytpl.js"></script>
        <script src="/jqPlugin/layer/layer.min.js"></script>
        <script src="/jqPlugin/laydate/laydate.js" type='text/javascript'></script>

        <script src="/themes/wStyle1/js/comm/VerifyJs.js"></script>
        <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
        <script src="/themes/wStyle1/js/comm/jsLayout.js"></script>

        <!--end JS引用-->
        <script type="text/javascript">
            $(function () {
                $.ploadFile("kindeditor", function (script, textStatus) {
                    $.setUploadFile('btnupImg', { FileId: '', RelId: "", rType1: '0', rType2: '' }, function (data) {
                        if (data.url) {
                            $('#logo_img_selected').empty().html('<img alt="" src="' + data.url + '" for="' + data.url + '">');
                        }
                    });
                });
            });

            (function () {
                var djackId = GetQueryStr("djackId");
                var djackName = GetQueryStr("djackName");
                $("#selCountry").find("option[value='DF6723BE-A25C-4F77-BB49-A1662D3E6F2A']").attr("selected", "selected");
                $("#djackId").val(djackName);
                $("#djackId").attr("data-value", djackId);
                btnDo("init");

            })();

            $("#selCountry").change(function () {
                btnDo("upCountry")
            });
            $("#selCity").change(function () {
                btnDo("upCity");
            })

            function btnDo(sEbtn) {
                GtGrid1Action = sEbtn;
                var opart = new jsonRow();
                if (sEbtn == "init") {
                    opart.AddCell("parentsId", "DF6723BE-A25C-4F77-BB49-A1662D3E6F2A");
                }
                else if (sEbtn == "upCountry") {
                    opart.AddCell("parentsId", $.trim($("#selCountry").val()));
                }
                else if (sEbtn == "upCity") {
                    opart.AddCell("parentsId", $.trim($("#selCity").val()));
                }
                opart.AddCell("ACTION", GtGrid1Action);
                ajaxComm(opart);
            }


            //显示地区
            function setCity(data, selectId, selectCity) {
                if (IsNull(data) || data.rows.length < 1) {
                    return;
                }
                $("#" + selectId).html("");
                var cityName = "";
                for (var i = 0; i < data.rows.length; i++) {
                    if (data.rows[i].COUNTRY_CITY_ID == selectCity) {
                        $("#" + selectId).append("<option selected='selected' value='" + data.rows[i].COUNTRY_CITY_ID + "'>" + data.rows[i].COUNTRY_CITY_NME + "</option>");
                        cityName = data.rows[i].COUNTRY_CITY_NME;
                    } else {
                        $("#" + selectId).append("<option value='" + data.rows[i].COUNTRY_CITY_ID + "'>" + data.rows[i].COUNTRY_CITY_NME + "</option>");
                    }
                }
                if (IsNull(cityName)) {
                    cityName = data.rows[0].COUNTRY_CITY_NME;
                }
            }

            function setSelect(inpuId, data) {
                if (IsNull(data)) {
                    return;
                }
                var select = $("#" + inpuId);
                select.html("");
                for (var i = 0; i < data.rows.length; i++) {
                    select.append("<option value='" + data.rows[i]["enum_Value"] + "'>" + data.rows[i]["enum_Name"] + "</option>")
                }

            }

            //执行AJAX调用时获取参数
            function addTransport() {


                //地接客
                var djackId = $.trim($("#djackId").attr("data-value"));
                if (IsNull(djackId)) {
                    layer.alert('请选择地接客', 3);
                    return;
                }

                //运输证号
                var transportNumber = $.trim($("#transportNumber").val());
                if (IsNull(transportNumber)) {
                    layer.alert('请填写车牌号', 3);
                    return;
                }

                if (transportNumber.length > 50) {
                    layer.alert("运输证号不能超过50个字符", 3);
                    return;
                }

                //业户名称
                var businessName = $.trim($("#businessName").val());
                if (IsNull(businessName)) {
                    layer.alert('业户名称不能为空', 3);
                    return;
                }
                if (businessName.length>50) {
                    layer.alert('业户名称不能超过50个字符', 3);
                    return;
                }

                var countryId = $.trim($("#selCountry").val());

                var countryName = $.trim($("#selCountry").find("option:selected").text());
                var cityId = $.trim($("#selCity").val());
                var cityName = $.trim($("#selCity").find("option:selected").text());
                var destinationId = $.trim($("#selDestination").val());
                var destinationName = $.trim($("#selDestination").find("option:selected").text());
                if (IsNull(countryId) || IsNull(countryName) || IsNull(cityId) || IsNull(cityName) || IsNull(destinationId) || IsNull(destinationName)) {
                    layer.alert('请选择住址', 3);
                    return;
                }
                //车牌号
                var vehicleNumber = $.trim($("#vehicleNumber").val());
                if (IsNull(vehicleNumber)) {
                    layer.alert("车牌号不能为空", 3);
                    return;
                }
                if (vehicleNumber.length > 10) {
                    layer.alert("车牌号不能超过10个字符", 3);
                    return;
                }
                var licenseNumber = $.trim($("#licenseNumber").val());
                if (IsNull(licenseNumber)) {
                    layer.alert("许可证号不能为空", 3);
                    return;
                }
                if (licenseNumber.length>20) {
                    layer.alert("许可证号不能超过20个字符", 3);
                    return;
                }
                //if (!IsPositiveFloat(price)) {
                //    layer.alert("价格只能是数字", 3);
                //    return;
                //}
                //车辆品牌
                var vehicleBrand = $.trim($("#vehicleBrand").val());
                if (IsNull(vehicleBrand)) {
                    layer.alert("车辆品牌不能为空", 3);
                    return;
                }
                //座位数
                var seats = $.trim($("#seats").val());
                if (IsNull(seats)) {
                    layer.alert("座位数不能为空不能为空", 3);
                    return;
                }
                if (!NonzeroPositiveInt(seats)) {
                    layer.alert("座位数只能是正整数",3);
                    return;
                }
                //经营范围
                var businessScope = $.trim($("#businessScope").val());
                if (IsNull(businessScope)) {
                    layer.alert("经营范围不能为空", 3);
                    return;
                }
                //发证日期
                var issuingDate = $.trim($("#issuingDate").val());
                if (IsNull(issuingDate)) {
                    layer.alert('发证日期不能为空', 3);
                    return;
                }

                //行驶证图片
                var transportPicture = $("#logo_img_selected").children().eq(0).attr("for");
                if (IsNull(transportPicture)) {
                    layer.alert('请选择运输证图片', 3);
                    return;
                }
                layer.load('正在保存中…', 3);
                var _jsParam = new jsonRow();

                _jsParam.AddCell("djackId", djackId);
                _jsParam.AddCell("transportNumber", transportNumber);
                _jsParam.AddCell("transportPicture", transportPicture);

                _jsParam.AddCell("businessName", businessName);
                _jsParam.AddCell("countryId", countryId);
                _jsParam.AddCell("countryName", countryName);
                _jsParam.AddCell("cityId", cityId);
                _jsParam.AddCell("cityName", cityName);
                _jsParam.AddCell("destinationId", destinationId);
                _jsParam.AddCell("destinationName", destinationName);
                _jsParam.AddCell("vehicleNumber", vehicleNumber);
                _jsParam.AddCell("licenseNumber", licenseNumber);
                _jsParam.AddCell("vehicleType", vehicleBrand);
                _jsParam.AddCell("seats", seats);
                _jsParam.AddCell("businessScope", businessScope);
                _jsParam.AddCell("issuingDate", issuingDate);
                _jsParam.AddCell("ACTION", "addTransport");

                ajaxComm(_jsParam);
            };
            function success() {
                layer.alert('添加成功', 1);
                setTimeout(function () {
                    location.reload();
                }, 2000);
            }
        </script>
    </div>
</body>
</html>

